package com.example.demo.service.impl;

import com.example.demo.dao.db1.UserDb1Mapper;
import com.example.demo.dao.dto.UserDTO;
import com.example.demo.service.UserDb1Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author
 * 用户 业务层实现
 */
@Service
@Slf4j
public class UserDb1ServiceImpl implements UserDb1Service {

    @Autowired
    private UserDb1Mapper userDb1Mapper;

    @Override
    public UserDTO queryUserById(Integer id) {
        return userDb1Mapper.queryUserById(id);
    }

    @Override
    public void insert(Integer id, String userName) {
        userDb1Mapper.insert(id, userName);
    }

    @Override
    public PageInfo<UserDTO> queryUserByPage() {
        PageHelper.startPage(1, 10);
        List<UserDTO> userDTOList = userDb1Mapper.queryUserByPage();
        return new PageInfo<>(userDTOList);
    }

}